#!/bin/bash

#必须是root用户才可以执行
if [ $UID -ne 0 ]; then
    echo "Superuser privileges are required to run this script."
    echo "e.g. \"sudo $0\""
    exit 1
fi

# 资源根目录
resourcebasepath=$(cd `dirname $0`; cd ../resource; pwd)

cd ${resourcebasepath}/redis

wget http://download.redis.io/releases/redis-4.0.6.tar.gz

tar -xzf redis-4.0.6.tar.gz

cd redis*
# 编译
make
# install
make install PREFIX=/usr/local/redis

/cp ${resourcebasepath}/redis/redis_template.conf /usr/local/redis/bin/redis.conf

cd /usr/local/redis/bin

./redis-server redis.conf

firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload

ps -ef|grep redis